#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include<QQmlContext>
#include<QSqlDatabase>
#include"sqlquerymodel.h"
#include<QtDebug>
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QSqlDatabase mydatabase=QSqlDatabase::addDatabase("QSQLITE");
      QString currentPath;
      currentPath=QCoreApplication::applicationDirPath();
      mydatabase.setDatabaseName(QString("%1/PatientReport.db").arg(currentPath));
      qDebug()<<"currentPaht is "<<currentPath;
      if(mydatabase.open())
         qDebug()<<"db open ok!";
      else {
          qDebug()<<"db open failed!";
      }
    SqlQueryModel *model1 = new SqlQueryModel(0);
    model1->setQuery("select * from PatientBaseInfo");
    QQmlApplicationEngine engine;
    engine.rootContext()->setContextProperty("myModel",model1);
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
